
let list = [{
        "org_id": 1,
        "id": 2,
        "description": null,
        "name": "研发部",
        "code": null,
        "parent_id": null
    }, {
        "org_id": 1,
        "id": 3,
        "description": "",
        "name": "测试部",
        "code": null,
        "parent_id": null
    }, {
        "org_id": 1,
        "id": 4,
        "description": "开疆展土",
        "name": "市场部",
        "code": null,
        "parent_id": null
    }, {
        "org_id": 1,
        "id": 5,
        "description": "",
        "name": "研发一部",
        "code": null,
        "parent_id": 2
    }
  ];

module.exports = {
  'GET /api/department': (req, res) => {
    setTimeout(function () {
      res.json({
        status_code: 0,
        data: list
      });
    }, 500);
  },

  'GET /api/department/:id': (req, res) => {
    console.log("req = " + JSON.stringify(req.query));
    const department = list.filter(d => d.id.toString() === req.query.id)[0];
    const data = { ...department, users: [] };
    setTimeout(function () {
      res.json({
        status_code: 0,
        data: data,
      });
    }, 500);
  },

}
